refactor: restructure validator with git package extraction and execution unit abstraction#38
Merged
refactor: restructure validator with git package extraction and execution unit abstraction#38
Conversation
- getEngineName, getDefaultConcurrency, getLanguageFromFile - parseJSON, parseValidationResponseFallback - filterChangesForRule, filterLLMRules - execution unit getters - findPolicyRule, mapViolationsToRules - groupRulesByEngine
- llmValidator.validator field (unused) - llmValidator.Validate() method (never called) - unused imports (runtime, sync)
- GetRepoInfo() (never used) - IsGitRepo() (never used)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
executionUnit)로 관리Changes
Git 패키지 추출
internal/validator/git.go→internal/git/changes.go로 이동GitChange→git.Change로 타입 이름 변경GetGitChanges()→git.GetChanges()로 함수 이동GetStagedChanges(),ExtractAddedLines()함수 이동internal/git/changes_test.go로 이동Execution Unit 추상화 도입
internal/validator/execution_unit.go신규 생성 (271 lines)executionUnit인터페이스 정의:Execute(),GetRuleIDs(),GetEngineName(),GetFiles()linterExecutionUnit: 동일 linter의 모든 규칙을 배치로 실행llmExecutionUnit: 단일 (파일, 규칙) 쌍을 LLM으로 검증Validator API 정리
LLMValidator→llmValidator로 비공개화 (내부 구현 상세)NewLLMValidator()→newLLMValidator()로 비공개화CheckRule()→checkRule()로 비공개화internal/validator/selector.go삭제 (263 lines) - execution unit으로 대체validator.go리팩토링: 4단계 검증 파이프라인 (RBAC → 규칙 그룹화 → 실행 단위 생성 → 병렬 실행)Roles 패키지 API 정리
ValidateFilePermissions(username, files)삭제 →ValidateFilePermissionsForRole(role, files)사용GetUserPolicyPath()→getUserPolicyPath()로 비공개화CurrentRoleExists()삭제소비자 코드 업데이트
internal/cmd/validate.go:git.Change,git.GetChanges()사용internal/mcp/server.go:git.GetChanges()호출로 변경테스트 업데이트
NewValidator+SetLLMProvider+ValidateChanges)validator.GitChange→git.Change타입 참조 변경기타
internal/linter/pylint/converter.go: 문자열 옵션 래핑 지침 프롬프트 추가